﻿namespace Microsoft.SharePoint.Client
{
    using System;
    using System.ComponentModel;
    using System.Xml;

    [ScriptType("SP.ListDataValidationFailure", ValueObject=true, ServerTypeId="{6e0bc783-53a2-4506-827f-135040524794}")]
    public sealed class ListDataValidationFailure : ClientValueObject
    {
        private string m_displayName;
        private string m_message;
        private string m_name;
        private ListDataValidationFailureReason m_reason;
        private ListDataValidationType m_validationType;

        protected override bool InitOnePropertyFromJson(string peekedName, JsonReader reader)
        {
            bool flag = false;
            string str = peekedName;
            if (str != null)
            {
                if (!(str == "ValidationType"))
                {
                    if (str == "Reason")
                    {
                        flag = true;
                        reader.ReadName();
                        this.m_reason = reader.ReadEnum<ListDataValidationFailureReason>();
                        return flag;
                    }
                    if (str == "Name")
                    {
                        flag = true;
                        reader.ReadName();
                        this.m_name = reader.ReadString();
                        return flag;
                    }
                    if (str == "DisplayName")
                    {
                        flag = true;
                        reader.ReadName();
                        this.m_displayName = reader.ReadString();
                        return flag;
                    }
                    if (str == "Message")
                    {
                        flag = true;
                        reader.ReadName();
                        this.m_message = reader.ReadString();
                    }
                    return flag;
                }
                flag = true;
                reader.ReadName();
                this.m_validationType = reader.ReadEnum<ListDataValidationType>();
            }
            return flag;
        }

        [EditorBrowsable(EditorBrowsableState.Never)]
        public override void WriteToXml(XmlWriter writer, SerializationContext serializationContext)
        {
            if (writer == null)
            {
                throw new ArgumentNullException("writer");
            }
            if (serializationContext == null)
            {
                throw new ArgumentNullException("serializationContext");
            }
            writer.WriteStartElement("Property");
            writer.WriteAttributeString("Name", "ValidationType");
            DataConvert.WriteValueToXmlElement(writer, this.ValidationType, serializationContext);
            writer.WriteEndElement();
            writer.WriteStartElement("Property");
            writer.WriteAttributeString("Name", "Reason");
            DataConvert.WriteValueToXmlElement(writer, this.Reason, serializationContext);
            writer.WriteEndElement();
            writer.WriteStartElement("Property");
            writer.WriteAttributeString("Name", "Name");
            DataConvert.WriteValueToXmlElement(writer, this.Name, serializationContext);
            writer.WriteEndElement();
            writer.WriteStartElement("Property");
            writer.WriteAttributeString("Name", "DisplayName");
            DataConvert.WriteValueToXmlElement(writer, this.DisplayName, serializationContext);
            writer.WriteEndElement();
            writer.WriteStartElement("Property");
            writer.WriteAttributeString("Name", "Message");
            DataConvert.WriteValueToXmlElement(writer, this.Message, serializationContext);
            writer.WriteEndElement();
        }

        [Remote]
        public string DisplayName
        {
            get
            {
                return this.m_displayName;
            }
        }

        [Remote]
        public string Message
        {
            get
            {
                return this.m_message;
            }
        }

        [Remote]
        public string Name
        {
            get
            {
                return this.m_name;
            }
        }

        [Remote]
        public ListDataValidationFailureReason Reason
        {
            get
            {
                return this.m_reason;
            }
        }

        [EditorBrowsable(EditorBrowsableState.Never)]
        public override string TypeId
        {
            get
            {
                return "{6e0bc783-53a2-4506-827f-135040524794}";
            }
        }

        [Remote]
        public ListDataValidationType ValidationType
        {
            get
            {
                return this.m_validationType;
            }
        }
    }
}

